#include<unistd.h>
#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>

int main ()
{
    int reader = open ("file", O_RDONLY);
    int writer = open ("file_copy", O_WRONLY | O_CREAT, 0644);

    char buff[4096] = {0};
    int ret = 0;
    while (1)
    {
	ret = read (reader, buff, sizeof(buff));
	if (ret > 0)
	{
	    write (writer, buff, ret);
	}else
	    break;
    }
    close (reader);
    close (writer);
}
